<?php
/**
 * Zend_Service_Netflix_User Class.
 * 
 * @author Armando Padilla, armando_padilla_81@yahoo.com
 * @package Zend_Service_Netflix
 */ 
class Zend_Service_Netflix_User {

	/**
	 * User Id
	 *
	 * @var String.
	 */
	public $id;
	
	/**
	 * First Name.
	 *
	 * @var String.
	 */
	public $firstName;

	/**
	 * Last Name.
	 *
	 * @var String.
	 */
	public $lastName;
	
	/**
	 * Can Instant Watch.
	 *
	 * @var Boolean
	 */
	public $canInstantWatch;
	
	/**
	 * Preferred Formats List
	 *
	 * @var Array
	 */
	public $preferredFormats = array();
	

	public function __construct(){}
	
	/**
	 * Load the catalog data from XML.
	 *
	 * @param SimpleXMLElement $simpleXmlObject
	 */
	public function loadXML(SimpleXMLElement $simpleXmlObject){
		
		//Set all properties
		$this->id 	           = (string)$simpleXmlObject->user_id;
		$this->firstName 	   = (string)$simpleXmlObject->first_name;
		$this->lastName  	   = (string)$simpleXmlObject->last_name;
		$this->canInstantWatch = (boolean)$simpleXmlObject->can_instant_watch;
		
		$xml = simplexml_load_string($simpleXmlObject->asXML());
		
		//Get all the formats
		$formats = $xml->xpath("preferred_formats/category");
		foreach($formats as $format){
			array_push($this->preferredFormats, (string)$format['term']);
		}
		
		
	}
	
	
}